import http from '@/service/index'
import { type LoginParams, type PermissionParmas } from '@/api/auth/types'

// 获取验证码
// 写一个方法  用这个文件调用axios 这个方法里面传入url 和参数 就帮我请求
export const getVerifyCodeApi = async (key: string) => {
  return await http.request({
    url: `/sys/randomImage/${key}`
  })
}

// 登录接口 post 传data
export const loginApi = async (data: LoginParams) => {
  return await http.request({
    url: '/sys/login',
    method: 'post',
    data
  })
}

// 退出登录
export const loginOutApi = async () => {
  return await http.request({
    url: '/sys/logout'
  })
}

// 获取权限菜单 及 权限 get 请求的参数 用params
export const getUserPermissionByTokenApi = async (params: PermissionParmas) => {
  return await http.request({
    url: '/sys/permission/getUserPermissionByToken',
    params
  })
}
